<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型</title>
</head>
<body>
    <script type="text/javascript">
        // 1.

        function A() { }
                A.prototype.n = 1
                var b = new A()
                A.prototype = {
                    n: 2,
                    m: 3,
                }
                var c = new A()
                console.log(b.n, b.m, c.n, c.m)// 1 un 2 3

        // 2.

        function Foo() {
                    Object.prototype.a = function () {
                        console.log('可访问a')
                    }
                }
                Function.prototype.b = function () {
                    console.log('可访问b')
                }
                var foo = new Foo()
                foo.a();//a
                foo.b();//un
                Foo.a();//a
                Foo.b();//b

    </script>
</body>
</html>